﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SystemManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		SE6.User curUsr = SessionMan.GetLoginUser();
		if (curUsr == null || !curUsr.IsSystemManager())
			Response.Redirect("Login.aspx");
		if (IsPostBack)
        {
            if (SystemMan.UpdateSystemConfigures(Request, Response))
                feedBack.Text="更新系统信息成功！";
            else
			   feedBack.Text="更新系统信息失败，请稍后再试！";
		}
		else
		{
            LoadData(SystemMan.GetSystemConfigures());
		}
		navMenu.InnerHtml = GUI.NavMenu(PageClass.SystemManager);
    }

    //根据数据库信息更新页面信息
    public Boolean LoadData(SystemConfigure cfg)
    {
        try
        {
            login.Checked = (cfg.SystemFunction & FounctionType.Login) == FounctionType.Login;
            register.Checked = (cfg.SystemFunction & FounctionType.Register) == FounctionType.Register;
            upload.Checked = (cfg.SystemFunction & FounctionType.UploadArchive) == FounctionType.UploadArchive;
            download.Checked = (cfg.SystemFunction & FounctionType.DownloadArchive) == FounctionType.DownloadArchive;
            leaveword.Checked = (cfg.SystemFunction & FounctionType.LeaveWord) == FounctionType.LeaveWord;

            ulPublicPoint.Text = cfg.UploadArchivePoint[0].ToString();
            ulSharePoint.Text = cfg.UploadArchivePoint[1].ToString();
            ulPrivatePoint.Text = cfg.UploadArchivePoint[2].ToString();
            ulSafePoint.Text = cfg.UploadArchivePoint[3].ToString();


            dlPublicPoint.Text = cfg.UploadArchivePoint[0].ToString();
            dlSharePoint.Text = cfg.UploadArchivePoint[1].ToString();
            dlPrivatePoint.Text = cfg.UploadArchivePoint[2].ToString();
            dlSafePoint.Text = cfg.UploadArchivePoint[3].ToString();

            return true;

        }
        catch (System.Exception ex)
        {
            return false;
        }
    }
}
